function ajaxRequest()
{
	var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]
	if (window.ActiveXObject)
	{
		for (var i = 0; i < activexmodes.length; i++)
		{
			try
			{
				return new ActiveXObject(activexmodes[i]);
			}
			catch (e)
			{
				alert('Ajax startup error');
			}
		}
	}
	else if (window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	else return false
}


function getStory(storyId)
{

	var mypostrequest = new ajaxRequest()
	mypostrequest.onreadystatechange = function ()
	{
			if (mypostrequest.readyState == 4)
			{

				if (mypostrequest.status == 200 || window.location.href.indexOf("http") == -1)
				{
					document.getElementById("contentBox").innerHTML = mypostrequest.responseText;
					document.title = document.getElementById('storyTitle').innerHTML;
				}
				else
				{
					alert("An error has occured making the request")
				}
			}
		}

	var parameters = "storyId=" + storyId;
	mypostrequest.open("POST", "ui/fullstory.php", true)
	mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	mypostrequest.send(parameters)

}


function toggle(elemtId) {

	me = document.getElementById('m' + elemtId);
	if (me.style.display == "none") {
		me.style.display = "block";
	} else {
		me.style.display = "none";
	}

	swapImage(elemtId);
}

function swapImage(elemtId)
{
	objImg = document.getElementById(elemtId);
	if (objImg.innerHTML.charCodeAt(0) == 9660)
	{
		objImg.innerHTML = objImg.innerHTML.replace(String.fromCharCode(9660), String.fromCharCode(9658))
	}
	else
	{
		objImg.innerHTML = objImg.innerHTML.replace(String.fromCharCode(9658), String.fromCharCode(9660))
	}
}

function send()
{
	var name= document.getElementById("name").value;
	var email= document.getElementById("email").value;
	var title= document.getElementById("title").value;
	var comment= document.getElementById("comment").value;

	var mypostrequest = new ajaxRequest();
	mypostrequest.onreadystatechange = function ()
	{
			if (mypostrequest.readyState == 4)
			{
				if (mypostrequest.status == 200 || window.location.href.indexOf("http") == -1)
				{
					document.getElementById("response").innerHTML = mypostrequest.responseText;

				}
				else
				{
					alert("An error has occured making the request")
				}
			}
		}

		var parameters = "name=" + name+"&email=" + email + "&title=" + title + "&comment=" + comment;
		mypostrequest.open("POST", "feedback.php", true)
		mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
		mypostrequest.send(parameters)


}